﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Gollie.Mail;
using Gollie.Mail.Queue.Service;
using Gollie.Service;
using System.Threading;

namespace TestService
{
	class Program
	{
		static void Main(string[] args)
		{
			MailService svc = new MailService();

			BulkMail bm = new BulkMail("<p>Dit is een <b>test</b></p> Dus", "SubjectTest");

			for (int i = 0; i < 1; i++)
			{
				bm.Add("e.goldstein@quicknet.nl");
			}

			svc.QueueBulk(bm);
/*
			string period = new DateTime(2014, 4, 1).ToString("MMM-yyyy");

			string email = "e.goldstein@quicknet.nl";
			string name = "Het frisse frietje";
			string bankaccount = "account";
			decimal deposits = 10000;
			decimal staffelFee = 24;
			decimal correctionFee = 0;
			decimal totalFee = 24;
			decimal vat = 0.79M;
			decimal alreadyPaid = 3000;
			decimal amountToPay = 6978;

			decimal totaldeductions = totalFee + vat + alreadyPaid;

			EMail e = new EMail();
			e.Name = "youvebeenpaid";
			MailService svc = new MailService();
			Dictionary<string, string> aargs = new Dictionary<string, string>()
				{
											{ "{tenaamstelling}", name },
											{ "{bankaccount}", bankaccount },
											{ "{aanhef}", "Geachte relatie,<br/><br/>" },
											{ "{deposits}", deposits.ToString("c2") },
											{ "{staffelfee}", staffelFee.ToString("c2") },
											{ "{correctionfee}", correctionFee.ToString("c2") },
											{ "{totalfee}", totalFee.ToString("c2") },
											{ "{vat}", vat.ToString("c2") },
											{ "{vatpercentage}", "21%" },
											{ "{alreadypaid}", alreadyPaid.ToString("c2") },
											{ "{paidnow}", amountToPay.ToString("c2") },
											{ "{deductions}", totaldeductions.ToString("c2") },
											{ "{minimumfee}", "€ 1,00"},
											{ "{period}", period }
				};


			e.Recipients = email;
			e.Args = aargs;

			svc.Queue(e);
			*/
			/*

			ServiceHelper.Sleep(5000, 500, CancellationToken.None);
			int testNum = 10;
			Collection<EMail> emails = new Collection<EMail>();

			for (int i = 0; i < testNum; i++)
			{

				Dictionary<string, string>  aargs = new Dictionary<string, string>();
				aargs["{aanhef}"] = i.ToString();
				aargs["{username}"] = "pipo de clown";

				EMail e = new EMail();
				e.Name = "accountactivated";
				e.Recipients = "async_testmail_" + i.ToString() + "_@hotmail.com";
				e.Args = aargs;

				emails.Add(e);
			}

			MailService svc = new MailService();
/*
			for (int i = 0; i < testNum; i++)
			{
				mailArgs["{aanhef}"] = i.ToString();
				email.Recipients = emailAddressesSync[i];
				svc.Queue(email);
			}
*/
			/*
			for (int i = 0; i < testNum; i++)
			{
				svc.QueueAsync(emails[i]);
				System.Threading.Thread.Sleep(70);
			}

			System.Threading.Thread.Sleep(4000);
			*/
		}
	}
}
